package com.beiing.tianshuai.tianshuai.anim;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.TextView;

import com.beiing.tianshuai.tianshuai.R;

/**
 * Created by Jinni on 2017/10/25 0025.
 */

public class LikeAnimator {

    public static void thumbAnimator(Context context, TextView view) {
        Drawable drawableLike = ContextCompat.getDrawable(context, R.drawable.ic_dynamic_praise_red);
        drawableLike.setBounds(0, 0, drawableLike.getMinimumWidth(), drawableLike.getMinimumHeight());
        view.setCompoundDrawables(drawableLike, null, null, null);
        AnimHelper.with(new PulseAnimator()).duration(1000).playOn(view);
    }

    public static void addOneTextAnimator(Context context, final TextView view) {
        Animation animation = AnimationUtils.loadAnimation(context, R.anim.add_like_anim);
        view.setVisibility(View.VISIBLE);
        view.startAnimation(animation);
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                view.setVisibility(View.GONE);
            }
        }, 1000);
    }

    public static void disLikeAnimator(Context context, TextView view) {
        Drawable drawableDisLike = ContextCompat.getDrawable(context, R.drawable.ic_dynamic_praise);
        drawableDisLike.setBounds(0, 0, drawableDisLike.getMinimumWidth(), drawableDisLike.getMinimumHeight());
        view.setCompoundDrawables(drawableDisLike, null, null, null);
    }
}
